package com.eastfair.projectcore.controller;

import com.eastfair.projectcore.dto.HotImagePointPageQuery;
import com.eastfair.projectcore.dto.HotImagePointSaveDTO;
import com.eastfair.projectcore.dto.HotImagePointUpdateDTO;
import com.eastfair.projectcore.entity.HotImagePoint;
import com.eastfair.projectcore.service.HotImagePointService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 电子橱窗点位表
 * </p>
 *
 * @author ligang
 * @date 2021-08-09
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/hotImagePoint")
@Api(value = "HotImagePoint", tags = "电子橱窗点位表")
public class HotImagePointController extends SuperController<HotImagePointService, Long, HotImagePoint, HotImagePointPageQuery, HotImagePointSaveDTO, HotImagePointUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Override
    public void handlerResult(IPage<HotImagePoint> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<HotImagePoint> hotImagePointList = list.stream().map((map) -> {
            HotImagePoint hotImagePoint = HotImagePoint.builder().build();
            //TODO 请在这里完成转换
            return hotImagePoint;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(hotImagePointList));
    }
}
